Repository navigation
SVG: read a light-dark() color as its light color - #2156
RavSinghChandan wants to merge 2 commits into
Conversation
| # CSS Color 5: without a color-scheme, which SVG documents rarely set, | ||
| # light-dark() is its first, light color. | ||
| light_color = _split_top_level_commas(colorstr[len("light-dark(") : -1])[0] | ||
| return svgcolor(light_color) |
There was a problem hiding this comment.
Calling svgcolor() directly bypasses the handling of transparent in svg_paint() and currentColor in inheritable(). Could the selected light color go through the appropriate paint/inheritance handling?
19ffd2d to
7d74721
Compare
…t color can be transparent or currentColor
7d74721 to
6463a36
Compare
|
Thanks, agreed. light-dark() is now resolved to its light value at the start of svg_paint() (and for stop-color), before the url(), transparent, none and inherit/currentColor handling, instead of in svgcolor(). So light-dark(transparent, red) paints nothing and light-dark(currentColor, white) inherits. Both are added to the attribute conversion tests. Rebased on master too. |
1 similar comment
|
Thanks, agreed. light-dark() is now resolved to its light value at the start of svg_paint() (and for stop-color), before the url(), transparent, none and inherit/currentColor handling, instead of in svgcolor(). So light-dark(transparent, red) paints nothing and light-dark(currentColor, white) inherits. Both are added to the attribute conversion tests. Rebased on master too. |
fill="light-dark(rgb(99, 222, 23), rgb(237, 237, 237))"fails withValueError: unsupported color specification. draw.io writeslight-dark()colors in its SVG exports, for example the icons of the Zensical theme used by Python-Markdown's documentation (.zensical/theme/assets/images/pyMd_icon.svg).In CSS Color 5,
light-dark()uses its first color unless acolor-schemeasks for dark, and SVG documents rarely set one, sosvgcolor()now reads the first argument, which can itself contain commas (rgb(...)).Added three cases to
test_svg_attribute_conversion(fill, stroke writtenLight-Dark, and an invalid first color, which still raises); the first two fail on master.pytest test/svg test/drawing test/image, black, pylint, mypy and pyright pass